var Index = {
	BANNER_COUNT: 3,
	indexInit: function(){
		Index.bannerInit();
		Index.tabInit();
	},
	bannerInit: function(){
	    var name = CurrentUser.category==30?"您还没有设置名称:":"You haven't give your name:";
	    var version = CurrentUser.category==30?"版本号:":"Version:";
		$("#photo").css("background-image", "url('" + (Core.id2url(CurrentUser)) + "')");
		$("#name").text(CurrentUser.name||name);
		$("#phone").text(CurrentUser.phone||"");
		$(".testCtn").text(version + Core.VERSION);
		var ctnW = $("#bannerCtn").width();
		var touchStartFun = function(){
			clearTimeout(Index.tmo);
		}
		var touchEndFun = function(){
			Index.tmo = setTimeout(function(){
				Index.slide.toNext();
			}, 1000*6);
			$(".switch").css("opacity", 0.4);
			$("#switch"+Index.slide.currentPoint).css("opacity", 1);
			var $el = $($("#slide").children()[Index.slide.currentPoint]);
		}
		Index.slide = Css3Flip("#slide", touchStartFun, touchEndFun);
		touchEndFun();
		$("#absoluteTitleCtn").removeClass("hide").addClass("ub");
	},
	tabInit: function(){
		var tab = Menu[CurrentUser.category].tab;
		var tabHtml = '';
		if(CurrentUser.category==30){
		   for (var i = Math.ceil(tab.length/4)-1; i >= 0; i --){
            tabHtml += '<div class="ub umb_p3">';
            for (var j = 3; j >= 0; j --){
                if (tab[i*4+j]){
                    tabHtml +=  '<div  id="' + tab[i*4+j][0] + '" class="ub-f1 ub-con ub_center ub-ver upb_p3"  ontouchstart="zy_touch()" onclick="Index.jump(\'' + tab[i*4+j][0] + '\',\'' + tab[i*4+j][1] + '\');">' + 
                                '    <div class="umb_p3">' + 
                                '        <div class="uw2p5 uh2p1 ub-img5 umt_p2 im_icon_' + tab[i*4+j][0] + ' imgEvent"></div>' + 
                                '    </div>' + 
                                '    <div class="ufp9 upb_p3 umt_p31">' + tab[i*4+j][1] + '</div>' + 
                                '</div>';
                } else {
                    tabHtml +=  '<div class="ub-f1 ub-con ub_center ub-ver upb_p3">' + 
                                '    <div class="">' + 
                                '        <div class="uw1p8 uh1p8 ub-img5"></div>' + 
                                '    </div>' + 
                                '    <div class="ufp9 upb_p3"></div>' + 
                                '</div>';
                }
            }
            tabHtml += '</div>';
        }
        $("#footerCtn").html(tabHtml); 
		}else{
		    for (var i = Math.ceil(tab.length/4)-1; i >= 0; i --){
            tabHtml += '<div class="ub umb_p3">';
            for (var j = 3; j >= 0; j --){
                if (tab[i*4+j]){
                    tabHtml +=  '<div  id="' + tab[i*4+j][0] + '" class="ub-f1 ub-con ub_center ub-ver upb_p3"  ontouchstart="zy_touch()" onclick="Index.jump(\'' + tab[i*4+j][0] + '\',\'' + tab[i*4+j][1] + '\');">' + 
                                '    <div class="umb_p3">' + 
                                '        <div class="uw2p5 uh2p1 ub-img5 umt_p2 im_icon1_' + tab[i*4+j][0] + ' imgEvent"></div>' + 
                                '    </div>' + 
                                '    <div class="ufp9 upb_p3 umt_p31">' + tab[i*4+j][1] + '</div>' + 
                                '</div>';
                } else {
                    tabHtml +=  '<div class="ub-f1 ub-con ub_center ub-ver upb_p3">' + 
                                '    <div class="">' + 
                                '        <div class="uw1p8 uh1p8 ub-img5"></div>' + 
                                '    </div>' + 
                                '    <div class="ufp9 upb_p3"></div>' + 
                                '</div>';
                }
            }
            tabHtml += '</div>';
        }
        $("#footerCtn").html(tabHtml);
		}
		
	},
	jump: function(url,title){
		SetLS("tab",{url: url,title: title});
		if(CurrentUser.category == Role.TYPE_FOREIGNER ){
		    lan = LANGUAGE.ENGLISH;
		}
		var lanPath = lan==0?"ch/":"en/";
		OpenNewWin("../"+lanPath+url);
	},
	userInit: function(){
		CurrentUser = GetLS("user");
		var name = CurrentUser.category==30?"您还没有设置名称:":"You haven't give your name:";
		$("#photo").css("background-image", "url('" + (Core.id2url(CurrentUser)) + "')");
		$("#name").text(CurrentUser.name||name);
		$("#phone").text(CurrentUser.phone||"");
	},
	focusPicSet:function(){
	    console.log("CurrentUser.category:"+CurrentUser.category);
        if(CurrentUser.category==30){
            $("#focusFirst").attr("style","background-image:url('../img/banner1.png');");
            $("#focusOne").attr("style","background-image:url('../img/banner2.png');");
            $("#focusTwo").attr("style","background-image:url('../img/banner3.png');");
        }else if(CurrentUser.category==20){
             $("#focusFirst").attr("style","background-image:url('../img/banner1e.png');");
            $("#focusOne").attr("style","background-image:url('../img/banner2e.png');");
            $("#focusTwo").attr("style","background-image:url('../img/banner3e.png');");
        }
	}
	
	
}